<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;

class CommonController extends Controller
{
    //文件上传
    public function upload()
    {
        $file = Input::file('Filedata');
        if($file->isValid()){                           //实例化
            $entension = $file->getClientOriginalExtension();//上传文件的后缀
            $newName = date('YmdHis').mt_rand(1000,9999).'.'.$entension;//重命名
            $path = $file->move(public_path().'/uploads',$newName);//文件存放位置
            $filePath = 'uploads/'.$newName;//文件路径
            return $filePath;
        }
    }
}
